
interface Info {
}

/* 定义第1个表示信息的类——联系方式，此类实现Info接口       */
class Contact implements Info {
    private String address;
    private String telephone;
    private String zipcode;

    Contact(String address, String telephone, String zipcode) {
        this.address = address;
        this.telephone = telephone;
        this.zipcode = zipcode;
    }

    @Override
    public String toString() {
        return "联系方式："+"\n"+"地址：" + address + "，电话：" + telephone + "，邮政编码：" + zipcode;
    }
}

/* 定义第2个表示信息的类——个人基本信息，此类实现Info接口       */
class Introduction implements Info {
    private String nativePlace;
    private String sex;
    private int age;

    Introduction(String nativePlace,String sex,int age){
        this.age = age;
        this.nativePlace = nativePlace;
        this.sex = sex;
    }
    @Override
    public String toString() {
        return "基本信息："+"\n"+"籍贯："+nativePlace+"，性别："+sex+"，年龄："+age;
    }
}

/* 定义Person类，类中info属性的类型使用泛型        */
class Person<T extends Info> {
    private String name;
    private T info;
    Person(String name, T info){
        this.name=name;
        this.info=info;
    }

    @Override
    public String toString() {
        return this.name+info.toString();
    }
}


public class Main {
    public static void main(String[] args) {
        Contact c = new Contact("北京市", "0103456789", "100088");
        Person<Contact> per1 = new Person<Contact>("张三", c);   //实例化Person对象,同时指定Contact类型
        System.out.println(per1);
        Introduction in = new Introduction("福建", "男", 30);
        Person<Introduction> per2 = new Person<Introduction>("李四", in);//实例化Person对象,同时指定Introductiont类型
        System.out.println(per2);
    }
}